import 'package:enterprise_v6_app/app/components/custom_app_bar.dart';
import 'package:enterprise_v6_app/app/components/custom_refresh.dart';
import 'package:enterprise_v6_app/app/components/special_operation/custom_icon_title_view.dart';
import 'package:enterprise_v6_app/app/components/special_operation/custom_title_chart_page.dart';
import 'package:enterprise_v6_app/app/core/core.dart';
import 'package:enterprise_v6_app/app/core/ext/widget_extension.dart';
import 'package:enterprise_v6_app/app/data/entities/application/basic_information/equip_instrument_entity.dart';
import 'package:enterprise_v6_app/app/modules/application/basic_information/equipment_facilities/interlock_list/interlock_list_controller.dart';
import 'package:enterprise_v6_app/router/app_pages.dart';

/// 联锁清单
class InterlockListPage extends StatelessWidget {
  InterlockListPage({super.key});

  final controller = Get.put(InterlockListController());

  @override
  Widget build(BuildContext context) {
    return GetBuilder(
        init: controller,
        builder: (_) {
          return Scaffold(
              appBar: CustomAppBar(
                titleText: '联锁清单',
              ),
              body: Container(
                color: const Color(0xffF5F5F6),
                padding: EdgeInsets.symmetric(horizontal: 14.w, vertical: 12.w),
                child: CustomEasyRefreshList<EquipInstrumentEntity>(
                  dataLoad: (pageIndex, pageSize, {String? search}) async {
                    return controller.getListData(pageIndex, pageSize, search: search);
                  },
                  isShowSearch: true,
                  itemBuilder: (EquipInstrumentEntity item, int index) {
                    return CustomTitleChartPage(
                      titleView: CustomIconTitleView(
                        title: item.instrumentLogo!,
                      ),
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Row(
                            children: [
                              Text(
                                '类型：',
                                style: TextStyle(
                                  fontSize: 13.sp,
                                  height: 1.2,
                                  fontWeight: FontWeight.w400,
                                  color: const Color(0xffA5A6B5),
                                ),
                              ),
                              Expanded(
                                  child: Text(
                                item.interlockDeviceTypeName!,
                                textAlign: TextAlign.right,
                                style: TextStyle(
                                  fontSize: 12.sp,
                                  height: 1.2,
                                  fontWeight: FontWeight.w400,
                                  color: const Color(0xff495061),
                                ),
                              ))
                            ],
                          ),
                        ],
                      ),
                    ).clickOnce(() {
                      Get.toNamed(AppRoutes.interlockDetails, arguments: item.id!);
                    });
                  },
                ),
              ));
        });
  }
}
